 /**
 * \file
 *           tlmRmtCfgSrvRpcCommonDesc.cpp
 * \brief
 *           RPC common descriptor implementation file.
 *
 * \par Author (last changes):
 *          - Zeng Jie
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 * \par Project Leader:
 *          -
 * \par Responsible Developer:
 *          - Zeng Jie
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 * \par Responsible Architect:
 *          - Zhang Fa
 *          - BUIC, Continental Automotive Holdings Co., Ltd.
 *
 * \par Project:
 *      DPCA2
 *
 * \par SW-Component:
 *      Telematics
 *
 * \par SW-Package:
 *      Telematics
 *
 * \par SW-Module:
 *      Telematics Application
 *
 * \par SW-Architecture Specification:
 *      DPCA2_TELEMATICS_SW_DD_07a_ready.doc
 *
* \par SW-Design Specification:
 *      DPCA2_TLM-RMTCFG_SW_DD_01d_released.doc
 *
 * \par SW-Test Case Specification:
 *
 * \par CM-Info:
 *
 * \note
 *      This is a note.
 *
 * \bug
 *      - there are no known bugs
 *
 * \par Module-History:
 *
 * \verbatim
 * Date                Author					Reason
 * 10 Dec 2013        Zeng Jie              Initial Creation
 * The latest entry at the head of the history list.
 * \endverbatim
 *
 * \par Copyright Notice:
 * Copyright (C) 2012 Continental Automotive Holdings Co., Ltd.
 * Alle Rechte vorbehalten. All Rights Reserved.\n
 * The reproduction, transmission or use of this document or its contents is
 * not permitted without express written authority.\n
 * Offenders will be liable for damages. All rights, including rights created
 * by patent grant or registration of a utility model or design, are reserved.
 *
 */

#include "tlmRmtCfgSrvRpcCommonDesc.h"
#include "tlmRmtCfgSrvApp.h"
#include "teleLogTrace.h"


//==============================================================================
// IMPLEMENTATION
//==============================================================================

/**
 * \brief	Constructor of tlmRmtCfgSrvRpcCommonDesc
 *
 * TestID: 
 *
 * \param p [in] struct used by RPC framework which consists of calling function id,
 * input & output parameters and etc
 *
 * \return - none
 * */
tlmRmtCfgSrvRpcCommonDesc::tlmRmtCfgSrvRpcCommonDesc(RPC_IOCTL_PTR p) : pIOCTL(p) {
    //#[ operation tlmRmtCfgSrvRpcCommonDesc(RPC_IOCTL_PTR)
    //#]
}

/**
 * \brief	destructor of tlmRmtCfgSrvRpcCommonDesc

 *
 * \param - none
 *
 * \return - none
 * */
tlmRmtCfgSrvRpcCommonDesc::~tlmRmtCfgSrvRpcCommonDesc() {
    //#[ operation ~tlmRmtCfgSrvRpcCommonDesc()
    //#]
}

/**
 * \brief  execute the corresponding RPC function by caller from another threads
 *
 * TestID: 
 *
 * \param - none
 *
 * \return - none
 */
void tlmRmtCfgSrvRpcCommonDesc::__execute() const {  /*DG CPP2ISQP-ISQP Metric 3-SCC_GRANT_0008*/
    //#[ operation __execute()

    if (NIL != this->pIOCTL->ac)
    {
    	switch(this->pIOCTL->dmFuncID)
    	{
    	          
		    case FUNCID_TLM_RMT_CFG_HANDLE_MSG:
                {

                    tlmRmtCfgSrvApp * m_pRmtCfgSrv = const_cast<tlmRmtCfgSrvApp*> (tlmRmtCfgSrvApp::GetInstance());
                    if(m_pRmtCfgSrv != NIL)
                    {
                    
                        m_pRmtCfgSrv->__OnReceiveMsg(*(reinterpret_cast<tlmServiceMsg **>(this->pIOCTL->lpInBuffer)));
                    }
                    else
                    {
	                    LOG_PRINT(DPCA_TELE_MAIN_ERROR,"[TLM_MSGSRV]:<tlmRmtCfgSrvRpcCommonDesc::%s>, m_pRmtCfgSrv is NIL\n", __FUNCTION__);
                    }

                    break;
                }

                //pay attention: Should not use reinterpret_cast below, as this class is child of multiple class, reinterpret_cast would convert to incorrect place.

                case FUNCID_TLM_RMT_CFG_HANDLE_PENDING_MSG:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->HandlePendingMsg();
                    break;
                }

                

                case FUNCID_TLM_RMT_CFG_HANDLE_SET_CFG_MSG:
                {
                    
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->HandleSetConfigMsg();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_SEND_CON_MSG:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->SendConMsg();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_SEND_ACK_MSG:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->SendAckMsg();
                   break;
                }

                case FUNCID_TLM_RMT_CFG_HANDLE_GET_CFG_MSG:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->HandleGetCfgMsg();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_SEND_PARA_MSG:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->SendParaMsg();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_GET_CFG_TIME_OUT:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnGetCfgTimeOut();
                    break;
                }
                case FUNCID_TLM_RMT_CFG_SET_CFG_TIME_OUT:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnSetCfgTimeOut();
                    break;
                }
                case FUNCID_TLM_RMT_CFG_INITIALIZATION:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnInitialization();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_SET_CFG_COMPLETE:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnCompleteSetCfg();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_GET_CFG_COMPLETE:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnCompleteGetCfg();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_SET_CFG_RETRY:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnSetCfgRetry();
                    break;
                }

                case FUNCID_TLM_RMT_CFG_GET_CFG_RETRY:
                {
			static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnGetCfgRetry();
                    break;
                }
                case FUNCID_TLM_RMT_CFG_CHECK_CONN_STATE:
                {
                    uint32_t para = *(reinterpret_cast<uint32_t*>(this->pIOCTL->lpInBuffer));
			 static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->CheckConnState(para);
                    break;
                }

                case FUNCID_TLM_RMT_CFG_CHECK_UNCOMP_MSG:
                {
			 static_cast<tlmRmtCfgSrvApp*>(this->pIOCTL->ac)->OnCheckUncompleteMsg();
                    break;
                }

         default:
    		break;
    	}
    }
    else
    {
        // will be replaced by assert or other fallback strategy
    }

    //#]
}

